package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.pojo.Menu;
import com.itheima.pojo.Permission;
import com.itheima.pojo.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;
import java.util.Set;

public interface RoleDao {
    Set<Role> findByUserId(Integer userId);
    List<Role> findAll();
    public void addRole(Role role);
    public void update(Role role);
    @Delete("delete from t_role where id = #{id}")
    public void delete(Integer id);
    public void addRoleAndMenu(Map map);
    public void addRoleAndPermission(Map map);
    public Page<Role> findPage(String condition);
    @Select("select * from t_permission")
    public List<Permission> findAllPermission();
    @Select("select * from t_menu")
    public List<Menu> findAllMenu();
    @Delete("delete from t_role_menu where role_id = #{id}")
    public void deleteRidAndMid(Integer id);
    @Delete("delete from t_role_permission where role_id = #{id}")
    public void deleteRidAndPid(Integer id);
    @Select("select count(*) from t_user_role where role_id = #{rid}")
    public Integer findUidAndRid(Integer rid);
    @Select("select * from t_role where id = #{id}")
    public Role findRoleById(Integer id);
    @Select("select menu_id from t_role_menu where role_id = #{id}")
    Integer[] findMidsByRid(Integer id);
    @Select("select permission_id from t_role_permission where role_id = #{id}")
    Integer[] findPidsByRid(Integer id);
}
